package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsCollect;
import com.qf.service.DtsCoollectSercice;
import com.qf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * @author Cc
 * @version 1.0
 */
@RestController
@CrossOrigin("*")
@RequestMapping("/admin/collect")
public class AdminCollectController {

    @Autowired
    private DtsCoollectSercice dtsCoollectSercice;

    /**
     * 接口地址 : http://localhost:8083/admin/collect/list?page=1&limit=20&sort=add_time&order=desc
     */
    @RequiresPermissions("admin:collect:list")
    @RequiresPermissionsDesc(menu = {"用户管理", "会员收藏"}, button = "查询")
    @GetMapping("/list")
    public Object list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       @RequestParam(defaultValue = "add_time") String sort,
                       @RequestParam(defaultValue = "desc") String order){

        IPage<DtsCollect> iPage = dtsCoollectSercice.page( page, limit, sort, order);

        HashMap map= new HashMap();
        map.put("total", iPage.getTotal());
        map.put("items", iPage.getRecords());
        return ResponseUtil.ok(map);

    }
}
